<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/html">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title></title>
  <link href="/styles/base.css" rel="stylesheet" type="text/css">
  <link href="/styles/public.css" rel="stylesheet" type="text/css">
  <link href="/js/ueditor/themes/default/css/umeditor.css" type="text/css" rel="stylesheet">
  <link href="/js/datepicker/datepicker.css" rel="stylesheet">
  <script type="text/javascript" src="/js/jquery.js"></script>
  <script type="text/javascript" charset="utf-8" src="/js/ueditor/umeditor.config.js"></script>
  <script type="text/javascript" charset="utf-8" src="/js/ueditor/umeditor.min.js"></script>
  <script type="text/javascript" src="/js/ueditor/lang/zh-cn/zh-cn.js"></script>
  <script type="text/javascript" src="/js/common.js"></script>
  <script type="text/javascript" src="/js/public.js"></script>
    <script src="/js/plugins/jquery-validation/jquery.validate.min.js"></script>
    <script src="/js/plugins/jquery-form/jquery.form.js"></script>

    <script>
        $(function () {
            $("#wendaForm").validate({
                rules: {
                    title: {
                        required: true,
                        minlength: 10
                    },
                    detailW: {
                        required: true,
                        minlength: 1
                    }
                },
                messages: {
                    title: {
                        required: "请输入问题标题",
                        minlength: "标题不能少于10个字"
                    },
                    detailW: {
                        required: "请输入问题描述",
                        minlength: "描述一下您的问题"
                    }
                }
            })


            //保存或发表
            $('#wenda_btn').click(function () {
                $("#wendaForm").ajaxSubmit(function (data) {
                    if(data.success){
                        window.location.href = "/wenda";
                    }else{
                        if (data.code == 102) {
                            alert(data.msg);
                        } else {
                            alert("操作失败");
                        }
                    }
                })
            })
        })

    </script>

</head>

<body>
    <#assign currentNav="问答">
    <#include "../common/navbar.ftl">



  <div class="wrapper">
    <div class="qt-container clearfix">
      <div class="qt-main">
          <form action="/wenda/save" method="post" id="wendaForm">

        <div class="crumb">
          <a href="/wenda/">旅游问答</a> &gt; <span>我要提问</span>
        </div>
        <div class="qt-tit">
          <h5>问题标题</h5>
          <div class="qt-con">
            <input type="text" placeholder="标题不小于10字哦" class="_j_title" name="title" id="title">
              <div class="err-tip"></div>
          </div>
        </div>


              <div class="pi-row">
                  <div class="pi-col pi-date" style="margin-left: 2%;"> <label for="isopen">请选择目的地</label>
                      <div class="pi-dropdown "style="text-align: left" >
                          <select name="dest.id" data-placeholder="请选择目的地" id="region" style="width: 150px;">
                                            <#list dests as r>
                                                <option value="${r.id!}">${r.name!}</option>
                                            </#list>
                          </select>

                          <script>
                              $("#region").val(${(tv.dest.id)!});
                          </script>
                      </div>
                  </div>
              </div>

              <div></br></div>

              <div class="pi-row">
                  <div class="pi-col pi-date" style="margin-left: 2%;"> <label for="isopen">请选择标签</label>
                      <div class="pi-dropdown "style="text-align: left" >
                          <select name="tag.id" data-placeholder="请选择标签" id="region" style="width: 150px;">
                                            <#list tags as r>
                                                <option value="${r.id!}">${r.name!}</option>
                                            </#list>
                          </select>

                          <script>
                              $("#region").val(${(tv.dest.id)!});
                          </script>
                      </div>
                  </div>
              </div>


          <div class="qt-tit">
              <h5>问题描述</h5>
              <div class="qt-con">
                  <input type="text" placeholder="可以仔细描述问题噢" class="_j_title" name="content" id="detailW">
                  <div class="err-tip"></div>
              </div>
          </div>

        <div class="publish_question">
            <input type="button" name="wenda_btn" id="wenda_btn" value="发布问题" class="qt-post-btn _j_publish" title="发布问题">
          <#--<a class="qt-post-btn _j_publish" title="发布问题">发布问题</a>-->
        </div>
        </form>

      </div>
      <div class="qt-sider">
        <div class="qts-tit">提问的正确姿势</div>
        <div class="qts-con">
          <p>1.问题要【具体】【真实】【诚恳】，问题较多，需全面阐述时，可以添加问题补充。结伴/交易/与旅行无关的提问将被删除。</p>
          <p>2.给问题添加目的地，并打上正确的标签将有助于更快地获得回答。</p>
        </div>
      </div>
    </div>
  </div>
</body>

</html>